package net.oschina.app.ui;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.widget.ImageView;
import android.widget.TextView;

import net.oschina.app.R;
import net.oschina.app.base.BaseVPAdapter;
import net.oschina.app.fragment.MeFragmentView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by admin on 2017/7/15.
 */

public class NewsActivity extends AppCompatActivity {
    @BindView(R.id.tabLayout)
    TabLayout tabLayout;
    @BindView(R.id.vp_pager)
    ViewPager vpPager;
    @BindView(R.id.iv_return)
    ImageView ivReturn;
    @BindView(R.id.tv_toolbar)
    TextView tvToolbar;
    @BindView(R.id.toolbar)
    Toolbar toolbar;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.news_activity_layout);
        ButterKnife.bind(this);
        BaseVPAdapter adapter = new BaseVPAdapter(getSupportFragmentManager(), this);
        Bundle extras = getIntent().getExtras();
        String[] stringArray = extras.getStringArray("toolbar_center");
        String toolbar_name = extras.getString("toolbar_name");
        int type = extras.getInt("type");
        tvToolbar.setText(toolbar_name);
        MeTab[] values = MeTab.values();
        if (stringArray != null) {
            for (int i = 0; i < stringArray.length; i++) {
                adapter.addTab(stringArray[i], values[type].getClz(), null);
            }
        }
        vpPager.setAdapter(adapter);
        tabLayout.setupWithViewPager(vpPager);

    }

    @OnClick(R.id.iv_return)
    public void onViewClicked() {
        finish();
    }
}
